﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Collaboris.Saf.Tests.Support.Actions
{
    using Engine;

    using Entities;

    /// <summary>
    /// demonstrats the usage of dynamic properties
    /// </summary>
    public class MarryCouple : ActionBase<Person>
    {
        public MarryCouple(Person spouse, Person husband, List<Person> friends)
        {
            this.Spouse = spouse;
            this.Husband = husband;
            this.Friends = friends;

            this.InitialiseCollections();
        }

        public MarryCouple()
        {
            this.InitialiseCollections();
        }

        private void InitialiseCollections()
        {
            this.Childs = new List<Person>();
            this.Friends = new List<Person>();
            this.GodParents = new List<Person>();
        }

        public Person SpecialFriend
        {
            get;
            set;
        }
        
        public List<Person> Childs
        {
            get;
            set;
        }
        
        public Person Spouse
        {
            get;
            set;
        }

        public Person Husband
        {
            get;
            set;
        }

        public List<Person> Friends
        {
            get;
            set;
        }

        public List<Person> GodParents
        {
            get;
            set;
        }

        public string Surname
        {
            get;
            set;
        }

        /// <summary>
        /// Undoes the action by attempting to roll back what was done in the Do.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="entity">The data entityList.</param>
        /// <returns>A <see cref="ProcessStatus"/> indicating the outcome of the Undo on the Action.</returns>
        protected override ProcessStatus UndoAction(SafContext context, Person entity)
        {
            throw new NotImplementedException();
        }
    }

    public class MarrySympsons : MarryCouple
    {
        public MarrySympsons(Person spouse, Person husband, List<Person> friends) : base(spouse, husband, friends)
        {
        }

        public MarrySympsons()
        {
        }

        /// <summary>
        /// Executes the Action using the values passed in by the Data Entity
        /// and the <see cref="SafContext"/>.
        /// </summary>
        /// <param name="context">
        /// A valid <see cref="SafContext"/> containing properties to run the Action with.
        /// </param>
        /// <param name="entity">
        /// A Valid <see cref="T"/> containing the parameters with which to run the Action with.
        /// </param>
        /// <returns>A <see cref="ProcessStatus"/> signifying the outcome of processing the Action.</returns>
        protected override ProcessStatus DoAction(SafContext context, Person entity)
        {
            this.Surname = "Sympson";
            
            // Lets make babies
            this.Childs.Add(new Person("Lisa", "Sympson", 10, null));
            this.Childs.Add(new Person("Bart", "Sympson", 14, null));

            return ProcessStatus.Success;
        }   
    }

    public class MarryDucks : MarryCouple
    {
        public MarryDucks(Person spouse, Person husband, List<Person> friends) : base(spouse, husband, friends)
        {
        }

        public MarryDucks()
        {
        }

        /// <summary>
        /// Executes the Action using the values passed in by the Data Entity
        /// and the <see cref="SafContext"/>.
        /// </summary>
        /// <param name="context">
        /// A valid <see cref="SafContext"/> containing properties to run the Action with.
        /// </param>
        /// <param name="entity">
        /// A Valid <see cref="T"/> containing the parameters with which to run the Action with.
        /// </param>
        /// <returns>A <see cref="ProcessStatus"/> signifying the outcome of processing the Action.</returns>
        protected override ProcessStatus DoAction(SafContext context, Person entity)
        {
            this.Surname = "Duck";
            
            // Lets make babies
            this.Childs.Add(new Person("Huey", "Duck", 10, null));
            this.Childs.Add(new Person("Dewey", "Duck", 10, null));
            this.Childs.Add(new Person("Louie", "Duck", 10, null));

            this.GodParents.Add(new Person("Shreck", "Monster", 123, null));
            this.GodParents.Add(new Person("Fiona", "Monster", 105, null));

            return ProcessStatus.Success;
        }           
    }

    public class MarryHueyLisa : MarryCouple
    {
        public MarryHueyLisa(Person spouse, Person husband, List<Person> friends) : base(spouse, husband, friends)
        {
        }

        public MarryHueyLisa()
        {
        }

        /// <summary>
        /// Executes the Action using the values passed in by the Data Entity
        /// and the <see cref="SafContext"/>.
        /// </summary>
        /// <param name="context">
        /// A valid <see cref="SafContext"/> containing properties to run the Action with.
        /// </param>
        /// <param name="entity">
        /// A Valid <see cref="T"/> containing the parameters with which to run the Action with.
        /// </param>
        /// <returns>A <see cref="ProcessStatus"/> signifying the outcome of processing the Action.</returns>
        protected override ProcessStatus DoAction(SafContext context, Person entity)
        {
            // Lets make babies
            this.Childs.Add(new Person("Little Huey", "Duck", 10, null));
            this.Childs.Add(new Person("Little Lisa", "Duck", 10, null));

            return ProcessStatus.Success;
        }
    }
}
